<template>
	<view class="profile-container">
		<!-- 顶部操作栏 -->
		<view class="top-bar">
			<view class="page-title"></view>
			<view class="top-actions">
				<view class="sign-in-btn" @click="signIn">
					<text class="sign-in-text">签到</text>
				</view>
				<view class="action-icon" @click="goToSettings">
					<text class="icon">⚙️</text>
				</view>
				<view class="action-icon" @click="goToMessages">
					<text class="icon">💬</text>
				</view>
			</view>
		</view>
		
		<!-- 用户信息区域 -->
		<view class="user-info-section">
			<view class="avatar-container">
				<view class="avatar">
					<text class="avatar-text">{{ userInfo.avatar }}</text>
				</view>
			</view>
			<view class="user-details">
				<text class="username">{{ userInfo.name }}</text>
				<view class="health-info">
					<text class="heart-icon">💗</text>
					<text class="health-number">{{ userInfo.health }}</text>
				</view>
				<view class="interests">
					<text class="interests-label">兴趣爱好</text>
					<text class="interests-content">{{ userInfo.interests }}</text>
				</view>
			</view>
		</view>
		
		<!-- 统计数据 -->
		<view class="stats-section">
			<view class="stat-item" v-for="(stat, index) in userStats" :key="index">
				<text class="stat-number">{{ stat.number }}</text>
				<text class="stat-label">{{ stat.label }}</text>
			</view>
		</view>
		
		<!-- 菜单列表 -->
		<view class="menu-section">
			<view class="menu-item" v-for="(item, index) in menuList" :key="index" @click="handleMenuClick(item)">
				<view class="menu-icon">
					<text class="icon-text">{{ item.icon }}</text>
				</view>
				<text class="menu-title">{{ item.title }}</text>
				<view class="menu-arrow">></view>
			</view>
		</view>
	</view>
</template>

<script setup>
import { ref, onMounted } from 'vue'

// 响应式数据
const userInfo = ref({
	name: '刘德海',
	health: '20',
	interests: '交友、游戏',
	avatar: '👩'
})

const userStats = ref([
	{ number: '1.3万', label: '关注' },
	{ number: '11', label: '收藏' },
	{ number: '12', label: '点赞' },
	{ number: '11', label: '优惠券' },
	{ number: '11', label: '道具' }
])

const menuList = ref([
	{
		icon: '📋',
		title: '服务订单',
		action: 'serviceOrders'
	},
	{
		icon: '❓',
		title: '提问订单',
		action: 'questionOrders'
	},
	{
		icon: '🛒',
		title: '商品订单',
		action: 'productOrders'
	},
	{
		icon: '⭐',
		title: '我的等级',
		action: 'myLevel'
	},
	{
		icon: '📍',
		title: '收货地址',
		action: 'shippingAddress'
	},
	{
		icon: '👥',
		title: '邀请好友',
		action: 'inviteFriends'
	},
	{
		icon: '🤝',
		title: '合作伙伴招募',
		action: 'partnerRecruitment'
	},
	{
		icon: '📝',
		title: '投诉建议',
		action: 'complaintSuggestion'
	},
	{
		icon: '🏛️',
		title: '虚拟道场',
		action: 'virtualDojo'
	}
])

// 方法
const signIn = () => {
	uni.showToast({
		title: '签到成功',
		icon: 'success'
	})
}

const goToSettings = () => {
	uni.navigateTo({ url: '/pages/profile/settings' })
}

const goToMessages = () => {
	uni.navigateTo({ url: '/pages/message/message' })
}

const handleMenuClick = (item) => {
	switch (item.action) {
		case 'serviceOrders':
			uni.navigateTo({ url: '/pages/profile/service-orders' })
			break
		case 'questionOrders':
			uni.navigateTo({ url: '/pages/profile/question-orders' })
			break
		case 'productOrders':
			uni.navigateTo({ url: '/pages/profile/product-orders' })
			break
		case 'myLevel':
			uni.navigateTo({ url: '/pages/profile/my-level' })
			break
		case 'shippingAddress':
			uni.navigateTo({ url: '/pages/profile/shipping-address' })
			break
		case 'inviteFriends':
			uni.navigateTo({ url: '/pages/profile/invite-friends' })
			break
		case 'partnerRecruitment':
			uni.navigateTo({ url: '/pages/profile/partner-recruitment' })
			break
		case 'complaintSuggestion':
			uni.navigateTo({ url: '/pages/profile/complaint-suggestion' })
			break
		case 'virtualDojo':
			uni.navigateTo({ url: '/pages/profile/virtual-dojo' })
			break
		default:
			uni.showToast({
				title: '功能开发中',
				icon: 'none'
			})
	}
}



// 生命周期
onMounted(() => {
	console.log('个人中心页面已挂载')
})
</script>

<style scoped>
.profile-container {
	min-height: 100vh;
	background: #f5f5f5;
}

/* 顶部操作栏 */
.top-bar {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 20rpx 30rpx;
	background: #ffffff;
	border-bottom: 1rpx solid #f0f0f0;
}

.page-title {
	font-size: 36rpx;
	font-weight: bold;
	color: #333333;
}

.top-actions {
	display: flex;
	align-items: center;
	gap: 20rpx;
}

.sign-in-btn {
	background: #4CAF50;
	padding: 10rpx 20rpx;
	border-radius: 8rpx;
}

.sign-in-text {
	color: #ffffff;
	font-size: 24rpx;
	font-weight: bold;
}

.action-icon {
	width: 60rpx;
	height: 60rpx;
	display: flex;
	align-items: center;
	justify-content: center;
}

.icon {
	font-size: 32rpx;
}

/* 用户信息区域 */
.user-info-section {
	display: flex;
	align-items: center;
	padding: 30rpx;
	background: #ffffff;
}

.avatar-container {
	margin-right: 30rpx;
}

.avatar {
	width: 120rpx;
	height: 120rpx;
	background: #f5f5f5;
	border-radius: 16rpx;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 2rpx solid #e0e0e0;
}

.avatar-text {
	font-size: 60rpx;
}

.user-details {
	flex: 1;
}

.username {
	display: block;
	font-size: 36rpx;
	font-weight: bold;
	color: #333333;
	margin-bottom: 15rpx;
}

.health-info {
	display: flex;
	align-items: center;
	margin-bottom: 15rpx;
}

.heart-icon {
	font-size: 28rpx;
	margin-right: 10rpx;
}

.health-number {
	font-size: 28rpx;
	color: #ff6b6b;
	font-weight: bold;
}

.interests {
	display: flex;
	align-items: center;
}

.interests-label {
	font-size: 26rpx;
	color: #666666;
	margin-right: 20rpx;
}

.interests-content {
	font-size: 26rpx;
	color: #333333;
}

/* 统计数据 */
.stats-section {
	display: flex;
	justify-content: space-around;
	padding: 30rpx;
	background: #ffffff;
	border-bottom: 1rpx solid #f0f0f0;
}

.stat-item {
	text-align: center;
}

.stat-number {
	display: block;
	font-size: 32rpx;
	font-weight: bold;
	color: #333333;
	margin-bottom: 8rpx;
}

.stat-label {
	font-size: 24rpx;
	color: #666666;
}

/* 菜单列表 */
.menu-section {
	padding-bottom: 40rpx;
}

.menu-item {
	display: flex;
	align-items: center;
	padding: 30rpx;
	border-bottom: 1rpx solid #f0f0f0;
	background: #ffffff;
}

.menu-item:last-child {
	border-bottom: none;
}

.menu-item:active {
	background: #f8f8f8;
}

.menu-icon {
	width: 60rpx;
	height: 60rpx;
	display: flex;
	align-items: center;
	justify-content: center;
	margin-right: 30rpx;
}

.icon-text {
	font-size: 32rpx;
}

.menu-title {
	flex: 1;
	font-size: 30rpx;
	color: #333333;
}

.menu-arrow {
	font-size: 30rpx;
	color: #cccccc;
	font-weight: bold;
}
</style>
